home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_railseek_m.cog < prev    next >
Text File  |  1998-02-25  |  16KB  |  525 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # WEAP_RAILSEEK_M.COG
  4. #
  5. # WEAPON 17 Script - Seeking Rail Detonator Gun
  6. #
  7. # This is a missile launcher type of weapon. It sends out an explosive device with
  8. #  two options, impact or trigger explosion. The charge with the trigger option will
  9. #  stick to a wall.
  10. #
  11. # - Not affected by MagSealed sectors/surfaces.
  12. #
  13. # [YB & CYW] + [RF]
  14. #
  15. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  16.  
  17.  
  18. symbols
  19.  
  20. model       povModel=skrv.3do                   local
  21. model       povModel_m=skrv_m.3do               local
  22. model       weaponMesh=skrg.3do                 local
  23. sound       mountSound=RailChargeArm01.WAV      local
  24. sound       dismountSound=PutWeaponAway01.wav   local
  25. sound       fireSound=RailChargeFire01.WAV      local
  26. sound       outSound=RailChargeEmpty01.WAV      local
  27. sound       failSound=weapfail.wav              local
  28.  
  29. thing       player                              local
  30.  
  31. keyframe    mountAnim=RldVmnt.key               local
  32. keyframe    dismountAnim=RldVdis.key            local
  33. keyframe    povfireAnim=RldVpst1.key            local
  34. keyframe    holsterAnim=kyhlstr.key             local
  35.  
  36. template    projectileB=+dudseek                local
  37.  
  38. template    lprojectile=+lhraildet              local
  39. template    projectile=+hraildet                local
  40. template    projectile2=+hraildet2              local
  41.  
  42. template    sprojectile=+raildet                local
  43. template    sprojectile2=+raildet2              local
  44.  
  45. template    NCRail=+nchraildet               local
  46. template    NCRail2=+nchraildet2             local
  47.  
  48. template        gtemp=ghost                                local
  49. thing            moochGhost=-1                            local
  50.  
  51. int         oldFlags                         local
  52.  
  53. #template exp=+raildet_exp     local
  54.  
  55. thing       rail                                local
  56. thing       target                              local
  57.  
  58. flex        fireWait=1.0                        local
  59. flex        powerBoost                          local
  60. flex        autoAimFOV=1                        local
  61. flex        holsterWait                         local
  62.  
  63. flex        fMaxDot                          local
  64. flex        dot                              local
  65. thing       tMaybe                           local
  66.  
  67. keyframe    railAnim=rld0anim.key               local
  68.  
  69. int         trackID=-1                          local
  70. int         mode                                local
  71. int         holsterTrack                        local
  72. int         iShotCounter=0                      local
  73.  
  74. int         selectMode=1                        local
  75.  
  76. int            data                                            local
  77.  
  78. int         i                                local
  79. #int         j                                local
  80. #int         k                                local
  81. #int         m                                local
  82.  
  83. #thing       RLauncher                        local
  84. #thing       RTarget                          local
  85. #thing       RProjectile                      local
  86.  
  87. #int         RailSlotID                       local
  88. #int         RailSlotID2                      local
  89. #int         RailSlotID3                      local
  90. #int         RailSlotID4                      local
  91. #int         RailSlotID5                      local
  92. #int         RailSlotID6                      local
  93. #int         RailSlotID7                      local
  94. #int         RailSlotID8                      local
  95. #int         RailSlotID9                      local
  96. #int         RailSlotID10                     local
  97. #int         RailSlotID11                     local
  98. #int         RailSlotID12                     local
  99. #int         RailSlotID13                     local
  100. #int         RailSlotID14                     local
  101. #int         RailSlotID51                     local
  102. #int         RailSlotID16                     local
  103. #int         RailSlotID17                     local
  104. #int         RailSlotID18                     local
  105. #int         RailSlotID19                     local
  106. #int         RailSlotID20                     local
  107. #
  108. #int         RailSlotDest                     local
  109. #int         RailSlotDest2                    local
  110. #int         RailSlotDest3                    local
  111. #int         RailSlotDest4                    local
  112. #int         RailSlotDest5                    local
  113. #int         RailSlotDest6                    local
  114. #int         RailSlotDest7                    local
  115. #int         RailSlotDest8                    local
  116. #int         RailSlotDest9                    local
  117. #int         RailSlotDest10                   local
  118. #int         RailSlotDest11                   local
  119. #int         RailSlotDest12                   local
  120. #int         RailSlotDest13                   local
  121. #int         RailSlotDest14                   local
  122. #int         RailSlotDest51                   local
  123. #int         RailSlotDest16                   local
  124. #int         RailSlotDest17                   local
  125. #int         RailSlotDest18                   local
  126. #int         RailSlotDest19                   local
  127. #int         RailSlotDest20                   local
  128. #
  129. #thing       RailSlotThing                    local
  130. #thing       RailSlotThing2                   local
  131. #thing       RailSlotThing3                   local
  132. #thing       RailSlotThing4                   local
  133. #thing       RailSlotThing5                   local
  134. #thing       RailSlotThing6                   local
  135. #thing       RailSlotThing7                   local
  136. #thing       RailSlotThing8                   local
  137. #thing       RailSlotThing9                   local
  138. #thing       RailSlotThing10                  local
  139. #thing       RailSlotThing11                  local
  140. #thing       RailSlotThing12                  local
  141. #thing       RailSlotThing13                  local
  142. #thing       RailSlotThing14                  local
  143. #thing       RailSlotThing51                  local
  144. #thing       RailSlotThing16                  local
  145. #thing       RailSlotThing17                  local
  146. #thing       RailSlotThing18                  local
  147. #thing       RailSlotThing19                  local
  148. #thing       RailSlotThing20                  local
  149.  
  150. #message     startup
  151. message     activated
  152. message     deactivated
  153. message     selected
  154. message     deselected
  155. #message     newplayer
  156. message     autoselect
  157. message     fire
  158. message     timer
  159. #message     trigger
  160.  
  161. end
  162.  
  163. # ========================================================================================
  164.  
  165. code
  166.  
  167. //startup:
  168. //   for (i = 0; i < 20; i = i + 1)
  169. //      RailSlotID[i] = -1;
  170. //   return;
  171.  
  172. fire:
  173.    player = GetSourceRef();
  174.    mode = GetSenderRef();
  175.  
  176.    // Check that the player is still alive.
  177.    if(GetThingHealth(player) <= 0)
  178.    {
  179.       Return;
  180.    }
  181.  
  182.    // Check Ammo - If we are out, autoselect best weapon.
  183.    if(GetInv(player, 91) < 1.0)
  184.    {
  185.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  186.       if(GetAutoSwitch() & 1)
  187.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  188.       Return;
  189.    }
  190.  
  191.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  192.  
  193.    jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  194.    SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);
  195.  
  196.    if (GetInv(player, 93) > 0.0)
  197.    {
  198.       mode = 2;
  199.  
  200.       rail = FireProjectile(player, projectileB, failSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x00, 1, 1);
  201.    }
  202.    else
  203.    {
  204.       tMaybe = FirstThingInView(player, 120, 100, 0x404);
  205.       fMaxDot = -1;
  206.       target = -1;
  207.  
  208.          // Search for the thing with the highest dot.
  209.       while (tMaybe != -1)
  210.       {
  211.          dot = ThingViewDot(player, tMaybe);
  212.  
  213.          if ((dot > fMaxDot) && (player != tMaybe))
  214.          {
  215.             target = tMaybe;
  216.             fMaxDot = dot;
  217.          }
  218.  
  219.          tMaybe = NextThingInView();
  220.       }
  221.  
  222. //        target = player;
  223.  
  224.       if (target != -1)
  225.       {
  226.             data = target;
  227.  
  228.             if (mode == 0)
  229.                 data = data + 5000;
  230.  
  231.             rail = FireProjectileData(player, lprojectile, fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, 1, 1, data);
  232.       }
  233.       else
  234.       {
  235.          rail = FireProjectile(player, sprojectile[mode], fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, 1, 1);
  236.       }
  237.    }
  238.  
  239.    // Provide a kick backwards
  240.    if (mode != 2)
  241.       ApplyForce(player, VectorScale(GetThingLVec(player), -40));
  242.    else
  243.       SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  244.  
  245.    ChangeInv(player, 91, -1.0);
  246.  
  247.    powerBoost = GetInv(player, 63);
  248.    ChangeFireRate(player, fireWait/powerBoost);
  249.  
  250.    Return;
  251.  
  252. # ........................................................................................
  253.  
  254. activated:
  255.    player = GetSourceRef();
  256.    mode = GetSenderRef();
  257.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  258.    powerBoost = GetInv(player, 63);
  259.    ActivateWeapon( player, fireWait/powerBoost, mode );
  260.    Return;
  261.  
  262. # ........................................................................................
  263.  
  264. deactivated:
  265.    player = GetSourceRef();
  266.    mode = GetSenderRef();
  267.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  268.    DeactivateWeapon( player, mode );
  269.    Return;
  270.  
  271. # ........................................................................................
  272.  
  273. selected:
  274.    player = GetSourceRef();
  275.  
  276.     if (moochGhost == -1)
  277.     {
  278.         moochGhost = CreateThing(gTemp, GetLocalPlayerThing());
  279.         SetThingParent(moochGhost, GetThingGuid(GetLocalPlayerThing()));
  280.     }
  281.  
  282.    PlayMode(player, 41);
  283.    PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
  284.    if (GetInv(player, 67) == 0.0)
  285.       jkSetPOVModel(player, povModel);    // Kyle hand
  286.    else
  287.       jkSetPOVModel(player, povModel_m);  // Mara Hand
  288.    SetArmedMode(player, 1);
  289.    jkSetWeaponMesh(player, weaponMesh);
  290.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  291.  
  292.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  293.    SetMountWait(player, GetKeyLen(mountAnim));
  294.    jkClearFlags(player, 0x5);
  295.    SetCurWeapon(player, GetWeaponBin(17));
  296.  
  297.    // Check Ammo - If we are out, autoselect best weapon.
  298.    if(GetInv( player, 91 ) < 1.0)
  299.    {
  300.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  301.       if(GetAutoSwitch() & 1)
  302.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  303.    }
  304.  
  305.    Return;
  306.  
  307. # ........................................................................................
  308.  
  309. deselected:
  310.    player = GetSourceRef();
  311.  
  312.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  313.    jkPlayPOVKey( player, dismountAnim, 0, 18 );
  314.  
  315.    holsterWait = GetKeyLen(holsterAnim);
  316.    SetMountWait(player, holsterWait);
  317.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  318.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  319.    if (trackID != -1)
  320.    {
  321.       jkStopPOVKey( player, trackID, 0 );
  322.       trackID = -1;
  323.    }
  324.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  325.  
  326.    Return;
  327.  
  328. # ........................................................................................
  329.  
  330. //newplayer:
  331. //   player = GetSourceRef();
  332. //
  333. //   // Make sure that if the player is respawning, the old mount isn't playing anymore.
  334. //   if (trackID != -1)
  335. //      jkStopPOVKey(player, trackID, 0);
  336. //
  337. //   Return;
  338.  
  339. # ........................................................................................
  340.  
  341. autoselect:
  342.    selectMode = GetSenderRef();
  343.    player = GetSourceRef();
  344.  
  345.    // If the player has the weapon
  346.    if(GetInv(player, GetWeaponBin(17)) != 0.0)
  347.    {
  348.       // If the player has ammo
  349.       if(GetInv(player, 91) != 0.0)
  350.       {
  351.  
  352.          // query for ammo
  353.          if(selectMode == -1)
  354.          {
  355.             ReturnEx(901.0);
  356.             Return;
  357.          }
  358.  
  359.          if((selectMode == 0) && !(GetAutoPickup() & 2))
  360.          {
  361.             ReturnEx(901.0);
  362.             Return;
  363.          }
  364.  
  365.          if((selectMode == 1) && !(GetAutoSwitch() & 2))
  366.          {
  367.             ReturnEx(901.0);
  368.             Return;
  369.          }
  370.  
  371.          if((selectMode == 2) && !(GetAutoPickup() & 2))
  372.          {
  373.             ReturnEx(901.0);
  374.             Return;
  375.          }
  376.  
  377.          ReturnEx(-2.0);
  378.          Return;
  379.  
  380.       }
  381.       else
  382.       {
  383.          ReturnEx(-1.0);
  384.          Return;
  385.       }
  386.    }
  387.    else
  388.    {
  389.       ReturnEx(-1.0);
  390.    }
  391.  
  392.    Return;
  393.  
  394. # ........................................................................................
  395.  
  396. timer:
  397.    if (GetSenderID() == 2)
  398.    {
  399.       StopKey(player, holsterTrack, 0.0);
  400.    }
  401. //   else if (GetSenderID() == 3500)
  402. //   {
  403. //      SetWeaponTarget(GetParam(0), GetParam(1), 450.0);
  404. //   }
  405.    Return;
  406.  
  407. //# ........................................................................................
  408. //
  409. //trigger:
  410. //      // Handle Seeking Rail Dets
  411. //   if(GetSourceRef() == 3500 || GetSourceRef() == 3501)
  412. //   {
  413. //      //print("Creating Rail Det!");
  414. //
  415. //         // Add this rail det to the projectile list (so that it
  416. //         // can be destroyed when it's doppelganger explodes).
  417. //      for (m = 0; m < 20; m = m + 1)
  418. //      {
  419. //         if (RailSlotID[m] == -1)
  420. //         {
  421. //            RailSlotID[m] = GetParam(2);
  422. //
  423. //            j = m;
  424. //
  425. //               // Break the for loop.
  426. //            m = 30;
  427. //         }
  428. //      }
  429. //
  430. //         // If there were no slots open, don't allow the rail det to be created
  431. //         // (we would wind up with a rail det buzzing around over someone's head
  432. //            // like an angry hornet, but never exploding).
  433. //      if (m == 20)
  434. //      {
  435. //         //print("No Slots available!");
  436. //         return;
  437. //      }
  438. //
  439. //      m = j;
  440. //
  441. //      RLauncher = GetParam(0);
  442. //      RTarget = GetParam(1);
  443. //
  444. //      if (RTarget == GetLocalPlayerThing())
  445. //      {
  446. ////            print("Firing Live Round!");
  447. //
  448. //         if (GetSourceRef() == 3500)
  449. //            RProjectile = FireProjectileLocal(RLauncher, projectile, fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, 1, 1);
  450. //         else
  451. //            RProjectile = FireProjectileLocal(RLauncher, projectile2, fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, 1, 1);
  452. //      }
  453. //      else
  454. //      {
  455. ////         print("Firing Dummy Round!");
  456. //
  457. //         if (GetSourceRef() == 3500)
  458. //            RProjectile = FireProjectileLocal(RLauncher, NCRail, fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, 1, 1);
  459. //         else
  460. //            RProjectile = FireProjectileLocal(RLauncher, NCRail2, fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, 1, 1);
  461. //      }
  462. //
  463. ////      print("Marking Projectile!");
  464. //
  465. //        if (RProjectile != -1)
  466. //        {
  467. //                // Note down the reference of this seeker.
  468. //            SetThingUserData(RProjectile, m);
  469. //    
  470. //                // Make sure ownership is correct.
  471. //            SetThingParent(RProjectile, GetThingGuid(RLauncher));
  472. //    
  473. //                // Note down the projectile thing.
  474. //            RailSlotThing[m] = RProjectile;
  475. //            RailSlotDest[m] = RLauncher;
  476. //    
  477. ////            Sleep(3.0);
  478. //
  479. //            SetTimerEx(0.3, 3500, RProjectile, RTarget);
  480. //        }
  481. //        else
  482. //        {
  483. //            RailSlotID[m] = -1;
  484. //        }
  485. //   }
  486. //   else if(GetSourceRef() == 3502)     // Destroy a dummy seeker
  487. //   {
  488. //      //print("Destroying Ghost Rail Det!");
  489. //
  490. //         // Search the list for a match.
  491. //      for (k = 0; k < 20; k = k + 1)
  492. //         if (RailSlotID[k] == GetParam(0))
  493. //            if (RailSlotDest[k] == GetParam(1))
  494. //            {
  495. //                    DestroyThing(RailSlotThing[k]);
  496. //               RailSlotID[k] = -1;
  497. //
  498. //               k = 30;
  499. //            }
  500. //   }
  501. //   else if(GetSourceRef() == 3503)     // Destroy a real seeker
  502. //   {
  503. //      //print("Destroying Real Rail Det!");
  504. //
  505. //        i = GetParam(0);
  506. //      j = RailSlotID[i];
  507. //
  508. //        if (j != -1)
  509. //        {
  510. //            RailSlotID[i] = -1;
  511. //    
  512. //            CreateThingAtPosOwner(exp, GetThingSector(GetParam(1)), GetThingPos(GetParam(1)), '0 0 0', RailSlotDest[i]);
  513. ////            SendTrigger(RailSlotDest[i], 3504, VectorX(GetThingPos(GetParam(1))), VectorY(GetThingPos(GetParam(1))), VectorZ(GetThingPos(GetParam(1))), GetThingSector(GetParam(1)));
  514. //            SendTrigger(-1, 3502, j, RailSlotDest[i], 0, 0);
  515. //        }
  516. //   }
  517. //   else if(GetSourceRef() == 3504)     // Create an explosion
  518. //   {
  519. //        CreateThingAtPosOwner(exp, GetParam(3), VectorSet(GetParam(0), GetParam(1), GetParam(2)), '0 0 0', GetLocalPlayerThing());
  520. //   }
  521. //
  522. //   Return;
  523.  
  524. end
  525.